﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SAP.WebServices;
using System.Data;
using ReadXMLFile;
using System.Collections;
using System.Globalization;
using Microsoft.ReportingServices.Rendering;
using Microsoft.Reporting.WebForms;
namespace SAP
{
    public partial class Popup_Requisition : System.Web.UI.Page
    {

        /*
         * 
     <?xml version="1.0" encoding="utf-8"?>
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
  
         */

        public static DataTable dtContents;
        public static DataTable dtHeader;
        private GeneralFunctions GF = new GeneralFunctions(HttpContext.Current.User.Identity.Name);
        int RequestID = -1;


        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                this.RequestID = Request.QueryString["requestID"] == null ? -1 : Request.QueryString["requestID"] == "" ? -1 : Int32.Parse(Request.QueryString["requestID"]);
                DataTable tbl = GF.RunQuery("select ID, RequestType, Manager_EmpID, xoff.EmpID, xoff.XMLString, xoff.Status from XML_Off xoff where ID = " + RequestID);
                if (tbl.Rows.Count < 1)
                    return;
                String xmlStr = tbl.Rows[0]["XMLString"].ToString();
                xmlObj xmlObject = new xmlObj();

                dtHeader = xmlObject.xmlStr2Ds(xmlStr).Tables[0];
                dtContents = xmlObject.xmlStr2Ds(xmlStr).Tables[1];

                object objReportDataSource = tbl;
                ReportViewer1.ShowPrintButton = true;
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsHeader", objReportDataSource));
                ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsXMLHeader", dtHeader));
                ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsXMLDetail", dtContents));
                ReportViewer1.LocalReport.Refresh();
            }

        }
     
    }
}